package org.example.seata.common.rabbitmq.listener;

import lombok.AllArgsConstructor;
import org.example.seata.common.rabbitmq.event.MessageFailEvent;
import org.example.seata.common.rabbitmq.handle.MessageFailHandler;
import org.example.seata.common.rabbitmq.message.MessageFail;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * @author hzq
 * @date 2021/12/3 13:35
 */
@Component
@AllArgsConstructor
public class MessageFailListener implements ApplicationListener<MessageFailEvent> {

    private final MessageFailHandler messageFailHandler;

    @Override
    public void onApplicationEvent(MessageFailEvent event) {
        MessageFail messageFail = (MessageFail) event.getSource();
        messageFailHandler.handler(messageFail);
    }
}
